package com.cyou.dream.context;

import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

@Data
public class RiskResult {

    private final boolean allow;

    private final List<RuleResult> ruleResults;

    public RiskResult(boolean allow, List<RuleResult> ruleResults) {
        this.allow = allow;
        this.ruleResults = ruleResults;
    }

    /**
     * 获取所有失败的规则
     */
    @SuppressWarnings("unused")
    public List<RuleResult> getFailedRules() {
        return ruleResults.stream()
                .filter(result -> !result.isPassed())
                .collect(Collectors.toList());
    }
}
